package com.mantru.iotpot.Home;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.mantru.iotpot.ApplicationClass;
import com.mantru.iotpot.R;

public class ErrorActivity extends AppCompatActivity {
    private String TAG = "ErrorActivity";
    private ApplicationClass ac;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_error);
        ac = (ApplicationClass) getApplication(); // 初始化 ApplicationClass
        Intent intent = getIntent(); // 获取启动该 Activity 的 Intent
        String errorCode = intent.getStringExtra("error_code");
        String errorDesc = intent.getStringExtra("error_desc");
        Log.d(TAG,"errorCode: " + errorCode + " errorDesc: " + errorDesc);
        ac.SaveLog("接收到主页传的参数。error_code: " + errorCode + " error_desc: " + errorDesc);
        TextView textView1 = findViewById(R.id.error_text1);
        TextView textView2 = findViewById(R.id.error_text2);
        textView1.setText("错误代码：" + errorCode);
        textView2.setText(errorDesc);

        findViewById(R.id.error_button).setOnClickListener(v -> finish());
    }
}